// OPTIMIZED: This file uses unified config entry pattern
/**
 * 项目反馈模型
 */
const BaseModel = require('./base_model');

class ProjectFeedbackModel extends BaseModel {
    constructor() {
        super();
        this.setCollection('project_feedback');
    }

    /**
     * 添加项目反馈
     * @param {Object} params 
     * @returns {Promise}
     */
    async insertProjectFeedback(params) {
        return await this.insert({
            projectId: params.projectId,
            userId: params.userId,
            content: params.content,
            createTime: this.time()
        });
    }

    /**
     * 获取项目反馈列表
     * @param {String} projectId 项目ID
     * @param {Object} page 分页参数
     * @returns {Promise}
     */
    async getProjectFeedbackList(projectId, page = {}) {
        return await this.getAll({
            projectId
        }, {
            sort: {
                createTime: -1
            },
            ...page
        });
    }
}

module.exports = ProjectFeedbackModel;